package pl.bizuteria.sklep.api.product;


import java.util.Map;

import com.google.web.bindery.requestfactory.shared.ServiceLocator;

public class ProductServiceLocator implements ServiceLocator {


	private final Map<Class<?>, Class<?>> objectMap;

	public ProductServiceLocator(Map<Class<?>, Class<?>> objectMap) {
		this.objectMap = objectMap;
	}
	
	public Object getInstance(Class<?> clazz) {
		try {
			return objectMap.get(clazz).newInstance();
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}

}
